package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.chat.TextComponent;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;

public class NeiLiHudSetProcedure {
	public static void execute(Entity entity) {
		if (entity == null)
			return;
		if ((entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new KungFuModVariables.PlayerVariables())).NeiLiHud) {
			{
				boolean _setval = false;
				entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
					capability.NeiLiHud = _setval;
					capability.syncPlayerVariables(entity);
				});
			}
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(new TextComponent("\u4F60\u7684\u5185\u529B\u6761\u663E\u793A\u8BBE\u7F6E\u4E3AUI\u6A21\u5F0F"),
						(false));
		} else {
			{
				boolean _setval = true;
				entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
					capability.NeiLiHud = _setval;
					capability.syncPlayerVariables(entity);
				});
			}
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(
						new TextComponent("\u4F60\u7684\u5185\u529B\u6761\u663E\u793A\u8BBE\u7F6E\u4E3A\u6570\u5B57\u6A21\u5F0F"), (false));
		}
	}
}
